from toee import *
from utilities import *

def san_dialog( attachee, triggerer ):
	if (attachee.has_met(triggerer)):
		triggerer.begin_dialog( attachee, 10 )
	else:
		triggerer.begin_dialog( attachee, 1 )
	return SKIP_DEFAULT

def san_heartbeat( attachee, triggerer ):
	if (not game.combat_is_active()):
		for obj in game.obj_list_vicinity(attachee.location,OLC_PC):
			if (is_safe_to_talk(attachee,obj)):
				obj.begin_dialog(attachee,10)
				game.new_sid = 0
	return RUN_DEFAULT

def san_dying( attachee, triggerer ):
	game.global_flags[696] = 1
	return RUN_DEFAULT

def make_otis_talk( attachee, triggerer, line):
	npc = find_npc_near(attachee,8014)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	return SKIP_DEFAULT

def make_elmo_talk( attachee, triggerer, line):
	npc = find_npc_near(attachee,8000)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	return SKIP_DEFAULT

def make_elistaria_talk( attachee, triggerer, line):
	npc = find_npc_near(attachee,14690)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		npc.turn_towards(attachee)
		attachee.turn_towards(npc)
	return SKIP_DEFAULT

def make_goons_talk( attachee, triggerer, line):
	npc = find_npc_near(attachee,14691)
	if (npc != OBJ_HANDLE_NULL):
		triggerer.begin_dialog(npc,line)
		attachee.turn_towards(npc)
	return SKIP_DEFAULT

def san_enter_combat( attachee, triggerer ):
	if (triggerer.type == obj_t_pc ):
		saduj = find_npc_near( attachee, 14689)
		if (saduj != OBJ_HANDLE_NULL):
			saduj.attack(triggerer)
	if (triggerer.type == obj_t_pc ):
		bouncer = find_npc_near( attachee, 14691)
		if (bouncer != OBJ_HANDLE_NULL):
			bouncer.attack(triggerer)
	if (triggerer.type == obj_t_pc ):
		bruiser = find_npc_near( attachee, 14692)
		if (bruiser != OBJ_HANDLE_NULL):
			bruiser.attack(triggerer)
	if (triggerer.type == obj_t_pc ):
		biffer = find_npc_near( attachee, 14693)
		if (biffer != OBJ_HANDLE_NULL):
			biffer.attack(triggerer)
	return RUN_DEFAULT